package
{
	import flash.utils.getDefinitionByName;
	
	import layouts.ILayout;
	
	import mx.containers.Canvas;
	import mx.controls.Label;
	import mx.core.Container;
	
	public dynamic class SlideThumb extends Canvas
	{
		private var thumb:Container;
		private var labIndex:Label;

		public function SlideThumb()
		{
			mouseChildren = false;
			buttonMode = true;
			
			labIndex = new Label();
			labIndex.styleName = "slideIndex";
			labIndex.filters = [yshow.instance.dsf];
			addChild(labIndex);
		}
		
		private var _slide:Slide;
		public function get slide():Slide{
			return _slide;
		}
		public function set slide(value:Slide):void{
			_slide = value;
			
			if(thumb && contains(thumb))			
				removeChild(thumb);
			var layoutRef:Class = getDefinitionByName(slide.slideData.layout) as Class;
			thumb = new layoutRef() as Container;
			thumb.width = 800; thumb.height = 600;
			thumb.scaleX = thumb.scaleY = yshow.instance.vbSlides.width/800;
			_slide.slideThumb = thumb as ILayout;
			_slide.slideThumb.slideData = slide.slideData;
			addChildAt(thumb,0);
		}
		
		public function get slideIndex():int{
			return int(labIndex.text) - 1;
		}
		public function set slideIndex(value:int):void{
			labIndex.text = (value + 1).toString();
		}
	}
}